//
//  MyGoodDeedService.m
//  homeland
//
//  Created by caesar on 14-8-8.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "MyGoodDeedService.h"
#import "GoodDeedEntity.h"
#import "MyGoodDeedItemCell.h"

@implementation MyGoodDeedService
NSMutableDictionary *params;
- (void)loadDataWithKey:(NSString *)keyOrNil{
    _currentPageNo = 1;
    if (self.dataList != nil || self.dataList.count > 0) {
        self.dataList = nil ;
    }
    _dataItemName = @"GoodDeedEntity";
    params = [NSMutableDictionary dictionary];
    [self doHttpPost:SERVER_URL_GOODDEED_LIST headers:nil path:[NSString stringWithFormat:@"/%d",_currentPageNo] parameters:params];
}

- (void)loadMoreDataWithKey:(NSString *)keyOrNil{
    if (!params || [params count]==0) {
        params = [NSMutableDictionary dictionary];
    }
    if (keyOrNil) {
        [params setValue:keyOrNil forKey:@"title"];
    } else {
        [params setValue:@"" forKey:@"title"];
    }
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [self doHttpPost:SERVER_URL_GOODDEED_LIST headers:nil path:[NSString stringWithFormat:@"/%d",_currentPageNo + 1] parameters:params];
}

- (CGFloat)heightForCellAtRow:(NSIndexPath *)index{
    
    return 44;
}

/**展示数据*/
- (void)configCell:(UITableViewCell *)cell atIndex:(NSIndexPath *)index{
    if (self.dataList == nil || self.dataList.count == 0) {
        return;
    }
    // evaluate content insertTime
    NSLog(@"index.row = %d",index.row);
    GoodDeedEntity *item = [self.dataList objectAtIndex:index.row];
    MyGoodDeedItemCell *tempCell = (MyGoodDeedItemCell *)cell;
    tempCell.backgroundColor = [UIColor whiteColor];
    tempCell.titleLable.text = [CommonUtil dealNullObject:item.title];
    
    NSString * state ;
    if ([[CommonUtil dealNullObject:item.status] isEqualToString:@"1"]) {
        state = @"已审核";
    }else{
        state = @"未审核";
    }
    
    tempCell.stateLable.text = state;
    
    tempCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
@end
